home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 017 (1988-06)(Swedish User Group of Amiga)(SE)(PD)[m doscopy][WB].zip
/
Camelot 017 (1988-06)(Swedish User Group of Amiga)(SE)(PD)[m doscopy][WB].adf
/
DMouse
/
dmouse.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-05-22
|
6KB
|
218 lines
/*
* DMOUSE.C V1.06 18 May 1988 (Aztec Compile, +L ... 32 bit ints)
* and link w/ c32.lib
*
* DMOUSE QUIT
* DMOUSE -a# -t# -s# -m# -c# -L0 -Rqqqq -A0 -Kcccc -Qqqqq -C cmd
*
* -a# # = acceleration, default 3. 1 to disable
* -t# # = mouse threshold before acceleration takes effect, def. 0
* (in pixels/event)
* -s# # = screen timeout, default 5min, 0 to disable
* -m# # = pointer timeout, default 5 secs,0 to disable
* -c# # = # of clicks to bring window to front
* -L0 Disable LeftMouseButton->WindowToFront (LMB+RMB->ToBack)
* -L1 Enable it
* -Rqqqq Set qualifier + RMB for Window/ScreenToBack (default LMB)
* -A0 Disable Auto-Activate window on mouse move
* -A1 Enable it
* -Kcccc Set key code in hex that activates cmd, def is escape
* -Qqqqq Set key qualifier in hex for keycode, def is left-amiga
* -C cmd Set command (must be last option on command line), def NewCli
*
* Note: The -Q Qualifiers usually must be or'd with x8000
* Note: The -R Qualifier should NOT be or'd with x8000.
*
*
* To remove, BREAK the CLI it ran under.
*
* TODO: mouse pointer sometimes gets turned on by intuition
*/
#include <stdio.h>
#include "dmouse.h"
#define VERSION 6
int Enable_Abort; /* CLI break enable */
main(ac, av)
char *av[];
{
register short i, j, len;
register long val;
register char *ptr;
register DMS *dms = FindPort(PORTNAME);
short exists = (dms != NULL);
short create = (dms == NULL);
short quit = 0;
Enable_Abort = 0;
if (create) {
dms = AllocMem(sizeof(DMS), MEMF_PUBLIC|MEMF_CLEAR);
dms->Version = VERSION;
dms->Acc = 3;
dms->STo = 5*60;
dms->MTo = 5;
dms->Code = 0x45;
dms->Qual = 0x8040;
dms->RQual= 0x4000;
dms->Clicks = 1;
dms->CLeft = dms->Clicks;
strcpy(dms->Cmd, "newcli");
dms->LMBEnable = 1;
dms->AAEnable = 1;
dms->NoSprData = AllocMem(12, MEMF_PUBLIC|MEMF_CHIP|MEMF_CLEAR);
dms->NoSprData[0] = 0xFE00;
dms->NoSprData[1] = 0xFF00;
}
for (i = 1; i < ac; ++i) {
ptr = av[i];
if (strcmp(ptr, "QUIT") == 0 || strcmp(ptr, "quit") == 0) {
quit = 1;
create = 0;
break;
}
val = atoi(ptr+2);
if (*ptr == '-') {
switch(ptr[1]) {
case 'a':
dms->Acc = val;
break;
case 'c':
if (val < 1)
val = 1;
dms->Clicks = dms->CLeft = val;
break;
case 't':
dms->AThresh = val;
break;
case 's':
dms->STo = val;
break;
case 'm':
dms->MTo = val;
break;
case 'L':
dms->LMBEnable = val;
break;
case 'R':
dms->RQual = ahtoi(ptr+2);
break;
case 'A':
dms->AAEnable = val;
break;
case 'K':
dms->Code = ahtoi(ptr+2);
break;
case 'Q':
dms->Qual = ahtoi(ptr+2);
break;
case 'C':
for (len = strlen(ptr+2) + 2, j = i + 1; j < ac; ++j)
len += strlen(av[j]) + 1;
strcpy(dms->Cmd, ptr + 2);
for (j = i + 1; j < ac; ++j) {
if (dms->Cmd[0])
strcat(dms->Cmd, " ");
strcat(dms->Cmd, av[j]);
}
break;
default:
puts("DMOUSE QUIT or");
puts("DMOUSE -a# -t# -s# -m# -L0 -Rqqqq -A0 -Kcccc -Qqqqq -C cmd");
printf("V1.%02d PUBLIC DOMAIN, Matthew Dillon, 14 May 1988\n\n", VERSION);
puts(" -a# Acceleration (default 3)");
puts(" -t# Accel. threshold (default 0)");
puts(" -s# Screen timeout (default 300)");
puts(" -m# Mouse timeout (default 5)");
puts(" -c# Set # of clicks for wintofront (default 1)");
puts(" -L0/1 LMB disable/enable (default 1=enabled)");
puts(" -Rqqqq RMB qualifier wintoback (default 4000=LMB)");
puts(" -A0/1 Auto-Activate Window disable/enable");
puts(" -Kcccc Command Key Code, default 45 = esc");
puts(" -Qqqqq Command Key Qualifier (must | with 8000)");
puts(" -C cmd cmd to run, must be last option");
puts("Note: LMB(or -R qualifier)(hold)+RMB = WindowToBack");
puts("\n");
puts("Additionaly, Any option may be modified while DMOUSE is active");
create = 0;
break;
}
}
}
if (!exists && create) {
PROC *proc;
printf("Installing DMouse, ");
fflush(stdout);
dms->Port.mp_Flags = PA_IGNORE;
dms->Port.mp_Node.ln_Pri = 0;
dms->Port.mp_Node.ln_Type= NT_MSGPORT;
dms->Port.mp_Node.ln_Name= AllocMem(sizeof(PORTNAME), MEMF_PUBLIC);
strcpy(dms->Port.mp_Node.ln_Name, PORTNAME);
NewList(&dms->Port.mp_MsgList);
dms->Segment = LoadSeg("l:DMouse-Handler");
if (!dms->Segment)
dms->Segment = LoadSeg("DMouse-Handler");
if (!dms->Segment) {
puts("Unable to find L:DMouse-Handler");
FreeMem(dms->Port.mp_Node.ln_Name, sizeof(PORTNAME));
create = 0;
} else {
AddPort(&dms->Port);
dms->ShakeTask = FindTask(NULL);
dms->ShakeSig = AllocSignal(-1);
proc = CreateProc(dms->Port.mp_Node.ln_Name, 1, dms->Segment, 4096);
Wait(1 << dms->ShakeSig);
FreeSignal(dms->ShakeSig);
exists = 1;
quit = dms->StartupError;
if (quit)
puts("Handler error");
else
printf("ok. DMouse V1.%02d, by Matthew Dillon. PUBLIC DOMAIN.\n", VERSION);
}
}
if (quit) {
if (exists) {
printf("Removing, ");
fflush(stdout);
dms->ShakeTask = FindTask(NULL);
dms->ShakeSig = AllocSignal(-1);
Signal(dms->HandTask, SBF_C);
Wait(1 << dms->ShakeSig);
FreeSignal(dms->ShakeSig);
RemPort(&dms->Port);
FreeMem(dms->Port.mp_Node.ln_Name, sizeof(PORTNAME));
UnLoadSeg(dms->Segment);
puts("ok");
}
exists = 0;
create = 0;
}
if (!exists) {
FreeMem(dms->NoSprData, 12);
FreeMem(dms, sizeof(DMS));
}
}
ahtoi(str)
register char *str;
{
register long val = 0;
register char c;
while (c = *str) {
val <<= 4;
if (c >= '0' && c <= '9')
val |= (c & 15);
else
val |= (c & 15) + 9;
++str;
}
return(val);
}